package com.atguigu.springcloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @USER: dayu Administrator
 * @DATE: 2020/3/25
 * @DESCRIPTION:
 */
@SpringBootApplication
@EnableDiscoveryClient
public class OrderZkApplication {
    public static void main(String[] args) {
        SpringApplication.run(OrderZkApplication.class, args);
    }

    /**
     * LoadBalanced 做负载均衡使用，直接调用zookeeper注册中心的服务名称，由zookeeper转发到provide service
     *
     * @return
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
